import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

// 创建 store 实例
export default new Vuex.Store({
  state: {
    user: {},
    chat: {}
  },
  mutations: {
    saveUser (state, user) {
      state.user = user
    },
    addChatInfo (state, chat) {
      state.chat = chat
    }
  },
  // 获取state数据, 然后对state中的数据进行一定处理后再返回
  getters: {
    isLogin (state) {
      if (state.user.hmUsername != null) {
        return true
      } else {
        return false
      }
    }
  }
})
